package com.brainardphotography.blog.web.admin;

import java.util.logging.Logger;

import com.brainardphotography.blog.dao.BlogEntryDAO;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.google.sitebricks.At;
import com.google.sitebricks.Show;
import com.google.sitebricks.http.Get;
import com.google.sitebricks.http.Post;

@At("/admin/blogEntry/:id")
@Show("BlogEntry.html")
public class EditBlogEntryPage extends BlogEntryForm {
	private static final long serialVersionUID = 3461118883680833427L;

	private static final Logger log = Logger.getLogger(EditBlogEntryPage.class.getName());
	
	@Inject
	private BlogEntryDAO entryDAO;

	
	@Get()
	public void get(@Named("id") String id) {
		log.info("Editing blog entry: " + id);
		setEntry(entryDAO.get(id));
	}

	@Post()
	public String post() {

		saveEntry();

		return "/admin";
	}
}
